home *** CD-ROM | disk | FTP | other *** search
- Path: news.voicenet.com!news
- From: David Zuckman <dzuckman@omni.voicenet.com>
- Newsgroups: comp.lang.c++
- Subject: Quick, easy question on externs...
- Date: Wed, 10 Jan 1996 16:44:28 -0500
- Organization: Voicenet - Internet Access - (215)674-9290
- Message-ID: <30F4333C.41A9@omni.voicenet.com>
- NNTP-Posting-Host: ivyland38.voicenet.com
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0b4 (WinNT; I)
-
- I got two source files:
-
- z1.cpp
- ======
- #include <iostream.h>
-
- extern int const x;
-
- void main( void ) {
- x;
- }
-
- z2.cpp
- ======
- int const x = 5;
-
- They compile and link fine (I'm using MS Visual C++ 2.1).
-
- I change the line in z1.cpp that reads
- x;
- to
- cout << x;
- and I get
-
- Incrementally linking...
- LINK : performing full link
- z1.obj : error LNK2001: unresolved external symbol "?x@@3HB (int const x)"
- WinDebug/dbx.exe : error LNK1120: 1 unresolved externals
-
- What gives?
-
- Please mailto:dzuckman@omni.voicenet.com
-
- ]:8) David A. Zuckman
- =======================================================================
- How to ride: Sit on horse. Listen to your instincts. Do the opposite
- of what they say.
-